package com.jmga.ecogasfinder.activities.gasstation;

import android.app.TabActivity;
import android.content.Intent;
import android.content.res.Resources;
import android.os.Bundle;
import android.util.Log;
import android.view.ViewGroup.LayoutParams;
import android.view.Window;
import android.widget.TabHost;

import com.jmga.ecogasfinder.R;
import com.jmga.ecogasfinder.providers.GasFinderProvider;
import com.jmga.ecogasfinder.vo.GasStation;

public class GasStationTabsViewActivity extends TabActivity {

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		GasStation gasStation = (GasStation) getIntent().getSerializableExtra(GasFinderProvider.KEY_STATION);
		Log.d(getClass().getName(), "onCreate: GasStation-data-received " + gasStation);
		super.onCreate(savedInstanceState);
		this.requestWindowFeature(Window.FEATURE_NO_TITLE);
		setContentView(R.layout.gas_station_tabs);
		getWindow().setLayout(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT);
		
		Resources res = getResources();
		TabHost tabHost = getTabHost();
		TabHost.TabSpec spec;
		Intent intent;
		
		intent = new Intent(this, GasStationDetailsActivity.class);
		intent.putExtra(GasFinderProvider.KEY_STATION, gasStation);

		spec = tabHost
				.newTabSpec("station")
				.setIndicator(getString(R.string.tab_gas_station_data_label),
						res.getDrawable(R.drawable.ic_tab_station))
				.setContent(intent);
		tabHost.addTab(spec);

		intent = new Intent(this, GasStationStatisticsActivity.class);
		intent.putExtra(GasFinderProvider.KEY_STATION, gasStation);
		spec = tabHost
				.newTabSpec("statistics")
				.setIndicator(getString(R.string.tab_gas_station_statistics_label),
						res.getDrawable(R.drawable.ic_tab_statistics))
				.setContent(intent);
		tabHost.addTab(spec);
		
		intent = new Intent(this, GasStationPricesActivity.class);
		intent.putExtra(GasFinderProvider.KEY_STATION, gasStation);
		spec = tabHost
				.newTabSpec("prices")
				.setIndicator(getString(R.string.tab_gas_station_prices_label),
						res.getDrawable(R.drawable.ic_tab_prices))
				.setContent(intent);
		tabHost.addTab(spec);
		
		tabHost.setCurrentTab(0);
	}

}